var _MessagUtil = require('utils/message.js');

exports.MESSAGE_ID = 'id';
exports.MESSAGE_DATA = 'data';

exports.ID_SHARE = 'share';
exports.ID_NAMEINPUT = 'nameinput';
exports.ID_NAMECHANGED = 'namechanged';
exports.ID_NAMECANCELED = 'namecanceled';
exports.ID_ADMOB = 'admob';
exports.ID_UI_BACK_CLICK = 'backclick';
exports.ID_UI_HANDLEBACK = 'handleback';

// ==========================
// true if ui not response for back click
// ==========================
var blindForBack = false;
exports.setBlindForBack = function (blind) {
    blindForBack = blind;
};
exports.isBlindForBack = function () {
    return blindForBack;
};

// ==========================
// all kinds of message
// ==========================
exports.obtainMessage = function (id, data) {
    var obj = {};
    obj[exports.MESSAGE_ID] = id;
    if (data) {
        obj[exports.MESSAGE_DATA] = data;
    }
    return obj;
};
exports.share = function (obj) {
    _MessagUtil.sendMessage(exports.obtainMessage(exports.ID_SHARE, obj));
};
exports.showInput = function () {
    _MessagUtil.sendMessage(exports.obtainMessage(exports.ID_NAMEINPUT));
};
exports.handleBack = function (handle) {
    _MessagUtil.sendMessage(exports.obtainMessage(exports.ID_UI_HANDLEBACK, {enable: handle}));
};

//// ==========================
//// send multip message with a single call
//// ==========================
//function Messages() {
//    this.mMessages = [];
//}
//Messages.prototype.showAds = function (p) {
//    this.mMessages.push(obtain$showAds(p));
//    return this;
//};
//Messages.prototype.hideAds = function () {
//    this.mMessages.push(obtain$hideAds());
//    return this;
//};
///**
// * @param handle
// * @returns {*}
// */
//Messages.prototype.handleBackPress = function (handle) {
//    this.mMessages.push(obtain$handleBackPress(handle));
//    return this;
//};
//Messages.prototype.send = function () {
//    var result = _MessagUtil.sendMessage(this.mMessages);
//    this.mMessages.splice(0, this.mMessages.length);
//    return result;
//};
//exports.messages = function () {
//    return new Messages();
//};